import Vue from "vue";
import Vuex from "vuex";
import {getToken, setToken, removeToken} from '@/utils/auth'

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    count: 0,
    right: 0,
    // username: getToken()
    username: '',
    isAdmin: 0
  },
  mutations: {
    increment(state) {
      state.count++
    },
    increment2(state) {
      state.right++
    },
    login(state, realname) {
      state.username = realname
    },
    loginout(state) {
      state.username = ''
    },
    sync() {
      this.state.username = getToken();
    }
  }
})

export default store
